var pos1=null;
var newGraph=null;
function createLine(graphFeature,parentItem)
{
    var newObject = Qt.createQmlObject('import SWTGraph 1.0; SWTLine {}',
        parentItem);
    return newObject;
}

function createGraph(msg)
{
    if(msg.action=="create" && msg.graphType=="Line")
    {

        createLine({},msg.parentItem);
    }
}
function mousePressed(mouse)
{

    if(pos1==null)
    {
        pos1=Qt.point(mouse.x,mouse.y);
        console.log("pos1:x="+mouse.x+",y="+mouse.y);
        newGraph=createLine({},graphView);
        newGraph.p1=pos1;
        newGraph.p2=pos1;
    }
    else if(newGraph)
    {
        newGraph.p2=Qt.point(mouse.x,mouse.y);
        console.log("pos2:x="+mouse.x+",y="+mouse.y);
        newGraph=null;
        pos1=null;
    }
}
function mouseMove(mouse)
{
    if(newGraph!=null)
    {
        console.log("pos2:x="+mouse.x+",y="+mouse.y);
        newGraph.p2=Qt.point(mouse.x,mouse.y);
    }
}
//WorkerScript.onMessage = function(msg) {
//    if(msg.action=="create" && msg.graphType=="Line")
//    {
//        console.log(msg.parentItem);
//        createLine({},msg.parentItem);
//    }
//}

